package com.feri.sh.core.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.feri.sh.common.pojo.dto.QuesAnsDto;
import com.feri.sh.core.entity.Question;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

public interface  QuestionDao extends BaseMapper<Question> {

    @Select("select q.name, q.details, q.count, u.username, a.content, a.ctime " +
            "from t_question q " +
            "left join t_answers a on q.id = a.qid " +
            "left join t_user u on u.id = a.uid " +
            "where q.id = #{id}")
    @Results({
            @Result(property = "name", column = "name"),
            @Result(property = "details", column = "details"),
            @Result(property = "count", column = "count"),
            @Result(property = "username", column = "username"),
            @Result(property = "content", column = "content"),
            @Result(property = "ctime", column = "ctime")
    })
    QuesAnsDto selectById2(int id);
}
